package com.chiasma.writogether.server;

import com.chiasma.writogether.rpc.LocalUserService;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

@SuppressWarnings("serial")
public class LocalUserServiceImpl extends RemoteServiceServlet implements LocalUserService {
	
	
	private UserService userService = UserServiceFactory.getUserService();
	
	public String getCurrentLoginUserNickname(){
//		System.out.println("In ServiceImpl Layer");
		User currentUser = userService.getCurrentUser();
		
//		System.out.println("Current User :"+currentUser.getNickname());
//		System.out.println("Current AuthDomain :"+currentUser.getAuthDomain());
//		System.out.println("Current User Email :"+currentUser.getEmail());
	
		if (currentUser != null)
			return currentUser.getNickname();
		else
			return null;
	}
	
	public String getLogoutUrl() {
		return userService.createLogoutURL("/"); 
	}
	
	public Boolean getIsUserAdmin() {
		return userService.isUserAdmin();
	}
}
